package com.blensmile.utils;

import android.view.animation.Interpolator;

/**
 * Created by Blensmile on 2017/2/9.
 */
public class WaveDampingInterpolator implements Interpolator {
    private float cycle = 3.0f;
    private float damping = 0.5f;//一阶线性衰减

    public WaveDampingInterpolator(float cycle, float damping){
        this.cycle = cycle;
        this.damping = damping;
    }

    public WaveDampingInterpolator(){
    }

    @Override
    public float getInterpolation(float input) {
//        float f ;
//        if(input<0.25){
//            f = 0.5f - 2*input;
//        }else if(input<0.75){
//            f = 2*input-0.5f;
//        }else {
//            f =2.5f-input*2;
//        }
//        return f;
        return (float)(0.5f+0.5f*(1f-damping*input)*Math.sin(2*Math.PI*cycle*input));
    }
}
